package com.niit.session8.javaapi;

import java.util.Scanner;

public class UserLogin {
	public static void main(String[] args) {
//		已知正确的用户名密码，请实现用户登录验证。验证次数最多3次
		String username = "trout";
		String password = "123456";
		Scanner sc = new Scanner(System.in);
		for (int i = 0; i <= 2; i++) {
			System.out.println("请输入用户名：");
			String name = sc.next();
			System.out.println("请输入用密码：");
			String pass = sc.next();
			
			if(username.equals(name)&& password.equals(pass)) {
				System.out.println("登录成功");
				break;
			}else {
				System.out.println("登录失败，还剩余"+(2-i)+"次");
			}
		}
	}

}
